<template>
  <el-dialog
    append-to-body
    :title="title"
    :visible.sync="dialogFormVisible"
    width="500px"
    @close="close"
  >
    <el-form ref="form" label-width="80px" :model="form" :rules="rules">
      <el-form-item label="当前状态为">
        <span v-if="actorScore == 0">未锁定</span>
        <span v-else>锁定</span>
      </el-form-item>

      <el-form-item label="选择状态" prop="value">
        <el-select v-model="form.value" clearable placeholder="请选择审核状态">
          <el-option
            v-for="item in options1"
            :key="item.id"
            :label="item.creClasName"
            :value="item.id"
            @click.native="optosall(item)"
          />
        </el-select>
      </el-form-item>
    </el-form>
    <template #footer>
      <el-button @click="close">取 消</el-button>
      <el-button type="primary" @click="save">确 定</el-button>
    </template>
  </el-dialog>
</template>

<script>
  import { genggai } from '@/api/jvzu'

  export default {
    name: 'TableEdit',
    data() {
      return {
        options1: [
          {
            id: '0',
            creClasName: '启用',
          },
          {
            id: '1',
            creClasName: '锁定',
          },
        ], //状态
        actorScore: '', //当前状态
        actorScorewo: '', //修改后的分数分数
        form: {
          //打分系统数据
          value: '',
          locked: '',

          id: '', //当前项的id
        },
        rules: {
          value: [
            {
              required: true,
              message: '请选择状态',
              trigger: 'change',
              type: 'string',
            },
          ],
        },
        title: '',
        dialogFormVisible: false,
      }
    },
    created() {},
    methods: {
      handleChange() {
        this.show = false
        setTimeout(() => {
          this.show = true
        }, 300)
      },
      async optosall(e) {
        this.form.locked = e.id
      }, //修改状态
      showEdit(row) {
        this.actorScore = row.locked

        this.form.id = row.id

        this.title = '更改状态'
        this.dialogFormVisible = true
      },
      close() {
        this.$refs['form'].resetFields()
        this.form = this.$options.data().form
        this.dialogFormVisible = false
      },
      save() {
        this.$refs['form'].validate(async (valid) => {
          if (valid) {
            const { msg } = await genggai(this.form)
            console.log(msg)
            this.$baseMessage(msg, 'success', 'vab-hey-message-success')
            this.$emit('fetch-data')
            this.close()
          }
        })
      },
    },
  }
</script>
